Skip to content

feat: show a busy session's queued messages in the preview - #385

Merged
brtkwr merged 1 commit into
mainfrom
feat/queued-messages
Nov 23, 2026
Merged

brtkwr merged 1 commit into
mainfrom
feat/queued-messages

Conversation

@brtkwr

@brtkwr brtkwr commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Opus 5.5 ✨

What changes

While a session is mid-turn, the messages it has queued and not taken in yet now show at the end of its preview, as Claude Code's own tab shows them: the message, then a dim ⎿ Queued. That covers messages typed in its tab, sent from ccs, and sent by another session (drawn under From <name>). Once Claude takes one in, it leaves the queue and shows as an ordinary message above. Claude Code's ctrl+enter to send now is left off, since only its tab has that key.

ccs sessions lists them too, as queued: lines (queued in --json), so list_sessions live lines get them as well. read_session doesn't: it has no live status to tell a stale queue from a real one, and its offsets count entries, so it isn't a small change.

Queued messages aren't messages: counts, unread, done, WHEN and the search ignore them (not searchable: the search text has to stay identical between full and incremental parses, so that isn't simple).

What Claude Code writes

Read from the 2.1.330 binary (the queue module that writes queue-operation lines) and checked against real transcripts, read-only:

line content meaning
enqueue the message joined the queue (an idle session enqueues and dequeues in the same millisecond)
remove the message, a reason left it: absorbed_mid_turn (then a queued_command attachment with its text), delivered_to_agent, cleared_on_cancel, dropped_by_hook
popAll / popOne one line per message pulled back into the prompt to edit
dequeue none taken in at a turn's start; the user line after it holds the text

A dequeue names no message, and Claude Code picks by priority (now, next, later), not strictly first in first out, so ccs matches by content instead: a remove or pop by its content, and otherwise the user line or queued_command the message became. A cross-session message is taken in wrapped differently from how it was queued (an "Another Claude session sent a message:" line, hop-chain dropped), so matching uses its body with whitespace collapsed, compared exactly. A substring match would let a short message like ok be dropped by an unrelated line. A queued_command after an absorbed_mid_turn remove is that message's copy, so it drops nothing, and the same text queued twice keeps the second.

Only messages enqueued after the last turn end are shown, and only while the session is busy or waiting: a turn that ends with messages queued takes them in at once, so anything older is one ccs never saw taken in.

Measured on this machine's transcripts: 1,128 have queue records, with about 79k enqueues, 49k dequeues and 30k removes. With exact matching, 70 messages are never seen taken in, mostly slash commands and ! commands, which show up as their output rather than as their text. After the turn-end filter, 3 remain across all transcripts, and those would show only if their session were running mid-turn.

Codex: its rollouts record only task_started, task_complete and turn_aborted, and nothing for a queued message, so Codex sessions show none.

Untrusted text

A queued message's text is cleaned where it enters (noteEnqueued), and so is Queued, the list kept for delivery status. TestUntrustedTextIsCleanedWhereItEnters now enqueues a typed message and a cross-session one carrying the poison, and checks the drawn preview and Plain(). The match keys stay raw because they're compared, never drawn.

Tests

  • internal/transcript/queue_test.go: a message typed mid-turn, the same text queued twice, dequeue then a cross-session user line, pop and remove, harness text skipped, the turn-end filter, Plain, and a removal never writing over a copy handed out earlier
  • TestPreviewShowsQueuedMessages: drawn while busy, hidden while idle, and moved into the conversation once taken in
  • TestSessionRowQueued: ccs sessions rows

No demo re-record: this adds rows to the preview, not a pane or layout.

🤖 Generated with Claude Code

A message that reaches a session mid-turn (typed in its tab, sent from
ccs, or from another session) waits in Claude Code's queue, which its tab
shows as "⎿ Queued" until Claude takes it in. The preview now shows the
same at its end, while the session is busy or waiting: each message, then
a dim "⎿ Queued". Once taken in it is an ordinary message above.

The queue comes from Claude Code's queue-operation lines: enqueue adds a
message; remove, popAll and popOne drop one by content; a dequeue names
none, so the user line or queued_command that follows is the message
taken in. Only messages enqueued since the last turn end count, since a
turn that ends with messages queued takes them in at once. Queued
messages aren't messages: counts, unread, done, WHEN and the search
ignore them.

ccs sessions lists them as queued: lines (queued in --json). Codex
rollouts record no queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brtkwr
brtkwr merged commit 8fef0df into main Nov 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant